<template>
  <div class="page-header-index-wide">
    <a-card
      :bordered="false"
      :bodyStyle="{ padding: '16px 0', height: '100%' }"
      :style="{ height: '100%' }"
    >
      <div
        class="account-settings-info-main"
        :class="{ 'mobile': isMobile }"
      >
        <div class="account-settings-info-left">
          <a-menu
            :mode="isMobile ? 'horizontal' : 'inline'"
            :style="{ border: '0', width: isMobile ? '560px' : 'auto'}"
            :selectedKeys="selectedKeys"
            type="inner"
            @openChange="onOpenChange"
          >
            <a-menu-item key="/account/settings/base">
              <router-link :to="{ name: 'BaseSettings' }">
                基础信息设置
              </router-link>
            </a-menu-item>
            <a-menu-item key="/account/settings/security">
              <router-link :to="{ name: 'SecuritySettings' }">
                修改密码
              </router-link>
            </a-menu-item>
          </a-menu>
        </div>
        <div class="account-settings-info-right">
          <div class="account-settings-info-title">
            <span>{{ $route.meta.title }}</span>
          </div>
          <router-view></router-view>
        </div>
      </div>
    </a-card>
  </div>
</template>

<script lang="ts">
import { RouteView } from '@/layouts'
import { AppMixin } from '@/mixin/app-mixin'
import { Mixins, Component, Watch } from 'vue-property-decorator'

@Component({
  components: {
    RouteView
  },
})
export default class AccountSetting extends Mixins(AppMixin) {
  // horizontal  inline
  mode= 'inline'
  openKeys: string[]= []
  selectedKeys= []

  // cropper
  preview= {}
  option= {
    img: '/avatar2.jpg',
    info: true,
    size: 1,
    outputType: 'jpeg',
    canScale: false,
    autoCrop: true,
    // 只有自动截图开启 宽度高度才生效
    autoCropWidth: 180,
    autoCropHeight: 180,
    fixedBox: true,
    // 开启宽度和高度比例
    fixed: true,
    fixedNumber: [1, 1]
  }

  pageTitle= ''

  mounted () {
    this.updateMenu()
  }

  @Watch('$route')
  public handlerRouteChange () {
    this.updateMenu()
  }

  onOpenChange (openKeys: string[]) {
    this.openKeys = openKeys
  }
  updateMenu () {
    const routes = this.$route.matched.concat()
    // @ts-ignore
    this.selectedKeys = [routes.pop().path]
  }
}
</script>

<style lang="less" scoped>
.ant-card {
  background: none;
  border: none;
}
.page-header-index-wide {
  height: calc(100% - 20px);
}
.account-settings-info-main {
  width: 1200px;
  display: flex;
  height: 100%;
  padding: 16px 0;
  box-sizing: border-box;
  margin: 0 auto;
  overflow: auto;
  background: #fff;
  &.mobile {
    display: block;

    .account-settings-info-left {
      border-right: unset;
      border-bottom: 1px solid #e8e8e8;
      width: 100%;
      height: 50px;
      overflow-x: auto;
      overflow-y: scroll;
    }
    .account-settings-info-right {
      padding: 20px 40px;
    }
  }

  .account-settings-info-left {
    border-right: 1px solid #e8e8e8;
    width: 224px;
  }

  .account-settings-info-right {
    flex: 1 1;
    padding: 8px 40px;

    .account-settings-info-title {
      color: rgba(0, 0, 0, 0.85);
      font-size: 20px;
      font-weight: 500;
      line-height: 28px;
      margin-bottom: 12px;
    }
    .account-settings-info-view {
      padding-top: 12px;
    }
  }
}
</style>
